package com.hxzy.mapper;

import com.hxzy.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * @author wzm
 * @create 2024-03-04 15:31
 * project_name:JavaWeb2401
 * @Description
 */
@Mapper
public interface EmpMapper {
    @Select("select count(1) from emp")
    Long count();

    @Select("select * from emp limit #{begin},#{pageSize}")
    List<Emp> getPage(Integer begin, Integer pageSize);

   /* @Select("select * from emp")*/
    List<Emp> getAll(String name, Short gender, LocalDate begin, LocalDate end);

    //删除员工的方法
    void deleteById(List<Integer> ids);

    @Insert("insert into emp(username,name,gender,image,job,entrydate,dept_id,create_time,update_time) " +
            "values(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp selectEmpById(Integer id);



    //更新员工的方法
    void updateById(Emp emp);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp getByUserNameAndPassWord(Emp emp);

    //根据部门id删除员工信息的方法
    @Delete("delete from emp where dept_id = #{id}")
    void deleteByDeptId(Integer id);
}
